package com.xinzhi.controller;

import com.xinzhi.pojo.Incomeandexpenditurerecord;
import com.xinzhi.pojo.dto.ShouZhi;
import com.xinzhi.service.recordService.IIncomeAndExpensesService;
import com.xinzhi.utils.Result;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;

@RestController
public class IncomeAndExpensesController {
    @Autowired
    private IIncomeAndExpensesService iIncomeAndExpensesService;

    /**
     * 收入和支出
     * @param pageNum 第几页
     * @param pageSize 一次显示多少
     * @param userId 用户id
     * @return
     */
    @GetMapping("/incomeAndExpenses")
    public Result selectIncomeAndExpenses(Integer pageNum, Integer pageSize,Integer userId){
        return iIncomeAndExpensesService.selectIncomeAndExpenses(pageNum,pageSize,userId);
    }

    /**
     * 根据收支情况及金钱范围进行查询
     * @param shouZhi
     * @return
     */
    @PostMapping("/selectBytype")
    public Result selectBytype(@RequestBody ShouZhi shouZhi){
        return iIncomeAndExpensesService.selectBytype(shouZhi);
    }

    /**
     * 根据卡号进行查询
     * @param zhi
     * @return
     */
    @PostMapping ("/selectByCard")
    public Result selectByCard(@RequestBody ShouZhi zhi){
        return iIncomeAndExpensesService.selectByCard(zhi);
    }

    /**
     * 根据时间进行查询
     * @param time
     * @param time2
     * @param userId
     * @return
     * @throws ParseException
     */
    @GetMapping ("/selectByTime")
    public Result selectByTime(String time,String time2 ,Integer userId) throws ParseException {
        return iIncomeAndExpensesService.selectByTime(time,time2,userId);
    }
}
